/*************************************************************************
    > File Name: main.c
    > Author: liujing
    > Mail: jingliu.cs@gmail.com 
    > Created Time: 2014年10月17日 星期五 20时37分20秒
 ************************************************************************/

#include "globals.h"
#include "util.h"
#include "scan.h"


int lineno = 0;
FILE * source;
FILE * listing;
FILE * code;
int EchoSource = FALSE;
int TraceScan = TRUE;
int Error = FALSE;

main(int argc, char * argv[]){
	char pgm[120];
    if (argc != 2){ 
		fprintf(stderr,"Usage: %s <filename>\n",argv[0]);
        exit(1);
    }
    strcpy(pgm,argv[1]) ;
    if(strchr(pgm,'.')==NULL){
		strcat(pgm,".c");
	}
	source = fopen(pgm,"r");
	if(source==NULL){ 
	  fprintf(stderr,"file %s not found\n",pgm);
	  exit(1);
    }
	listing = stdout; // In this lab print to stdout
	fprintf(listing,"\nC_minus lexical analyzation: %s\n",pgm);
	while (getToken()!=ENDFILE);
	fclose(source);
	return 0;
}


